# -*- coding: utf-8 -*-

def index():
    if not session.user_name:
        if session.sip_dict:
            sip_dict = session.sip_dict

            appId = sip_dict['appId']
            appInstanceId = sip_dict['appInstanceId']
            token = sip_dict['token']
            userId = sip_dict['userId']
            
            validate_user_data = sip.alisoft.validateUser(appId, appInstanceId, userId, token)

            if validate_user_data['response'] == '1':
#            if validate_user_data['String'] == '1':
                session.user_name = sip.alisoft.udb.getDomainLoginId(appId, domainid = '3', userid = userId,)['result']
                redirect(URL(r=request, c = 'default'))
        else:
            redirect(URL(r=request, c = 'default'))
    else:
        redirect(URL(r=request, c = 'default'))

    return dict(
        )